package fr.uniscol.model;

import java.io.Serializable;

public class Devoir implements Serializable {
	
	private ServiceEnseignant serviceEnseignant = null;
	
	private int code = 0;
	
	private String libelle = null;
	
	private String commentaire = null;
	
	private float coefficient = 1.0f;
	
	private Periode periode = null;

	public Devoir() {
		super();
	}

	public Devoir(int code, String libelle) {
		super();
		this.code = code;
		this.libelle = libelle;
	}
	
	public String getId(){
		return serviceEnseignant.getId() + "-" + getCode();
	}
	
	public void setId(String id){
	}

	public ServiceEnseignant getServiceEnseignant() {
		return serviceEnseignant;
	}

	public void setServiceEnseignant(ServiceEnseignant serviceEnseignant) {
		this.serviceEnseignant = serviceEnseignant;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getLibelle() {
		if(libelle == null){
			libelle = "";
		}
		return libelle;
	}

	public void setLibelle(String libelle) {
		this.libelle = libelle;
	}

	public String getCommentaire() {
		if(commentaire == null){
			commentaire = "";
		}
		return commentaire;
	}

	public void setCommentaire(String commentaire) {
		this.commentaire = commentaire;
	}

	public float getCoefficient() {
		return coefficient;
	}

	public void setCoefficient(float coefficient) {
		this.coefficient = coefficient;
	}

	public Periode getPeriode() {
		return periode;
	}

	public void setPeriode(Periode periode) {
		this.periode = periode;
	}

	@Override
	public boolean equals(Object obj) {
		Devoir d = (Devoir)obj;
		
		return getCode() == d.getCode();
	}
}
